<template>
  <div>
    <el-dialog
      title="批量策略管理"
      :visible="dialogVisible2"
      width="32%"
      @close="handleClose"
    >
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
        <el-form-item label="活动区域" prop="region">
          <el-select v-model="ruleForm.policyId" placeholder="请选择活动区域">
            <el-option v-for="item in amendStrategy" :key="item.policyId" :label="item.policyName" :value="item.policyId" />
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="submitStrategy">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { strategySubmitAPI } from '@/api/vmIndex'
export default {
  name: 'DialogPiliang',
  components: {},
  props: {
    dialogVisible2: {
      type: Boolean,
      default: false
    },
    amendStrategy: {
      type: Array,
      default: () => []
    },
    innerCode: {
      type: String,
      required: true
    }

  },
  data() {
    return {
      ruleForm: {
        policyId: ''
      },
      rules: {},
      innerCodeList: [], // 售货机编号列表
      policyId: '' // 策略id
    }
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    handleClose() {
      this.$emit('update:dialogVisible2', false)
    },
    async submitStrategy() {
      // console.log(this.innerCode)
      this.innerCodeList.push(this.innerCode)
      // console.log(this.ruleForm.policyId)
      this.policyId = this.ruleForm.policyId
      await strategySubmitAPI(this.innerCodeList, this.policyId)
      this.handleClose() // 关闭窗口
      // 重新刷新页面
      this.$emit('refreshList')
      // 把innerCodeList制空
      this.innerCodeList = []
    }
  }
}
</script>

<style scoped>

</style>
